#include <string>
#include <memory>
#include <iostream>

#include "Symbol.h"

BaseSymbol::BaseSymbol() {

}
void BaseSymbol::setName(std::string name) {
    this->name = name;
    return;
}

std::string BaseSymbol::getName() {
    return this->name;
}

void BaseSymbol::setType(std::string name) {
    this->type = name;
}

std::string BaseSymbol::getType() {
    return this->type;
}


void BaseSymbol::setValue(llvm::Value* value) {
    this->value = value;
    return;
}

llvm::Value* BaseSymbol::getValue() {
    return this->value;
}

llvm::AllocaInst* BaseSymbol::getAddr() {
    return this->addr;
}

void BaseSymbol::setAddr(llvm::AllocaInst* addr) {
    this->addr = addr;
}

bool SymbolTable::contains(const std::string name) {
    if (this->table.count(name) == 0) {
        return false;
    }
    else {
        return true;
    }
}
bool SymbolTable::insert(std::shared_ptr<BaseSymbol> symbol) {
    if (this->contains(symbol->getName())) {
        return false;
    }
    else {
        this->table[symbol->getName()] = symbol;
        return true;
    }
}
std::shared_ptr<BaseSymbol> SymbolTable::find(const std::string &name) {
    return this->table.at(name);
}